<?php
use yii\helpers\Url;
?>
<link rel="stylesheet" type="text/css" href="css/list.css"/>
<div class="content">
    <div class="box-head">
        <span class="width4">排序</span>
        <span class="width14">公司名称或个人名称</span>
        <span class="width9">联系邮箱</span>
        <span class="width12 ">申请时间</span>
        <span class="width14">操作</span>
        <span class="width9 text-r float-r">批量
            <select class="input-select float-r" name="status">
                <option value="-1" selected = "selected" >选择</option>
                <option value="0">删除</option>
            </select>
        </span>
    </div>
    <ul id="list">
        <?php if($model):?>
            <?php foreach($model as $key=>$val):?>
                <li>
                    <p class="width4"><?= $key+($data['nowpage']-1)*$data['limits']+1; ?></p>
                    <p class="width14"><?= $val['firm']; ?></p>
                    <p class="width9 red"><?= $val['email'];?></p>
                    <p class="width12"><?= date('Y-m-d',$val['time']); ?></p>
                    <p class="width14">
                        <a class="delete-one" href="<?= \yii\helpers\Url::to(['/join/delete','id'=>$val['id'],'page'=>$data['nowpage']]); ?>"><i class="icon-trash icon-large"></i></a>
                        <a class="update-one" href="<?= \yii\helpers\Url::to(['/join/show','id'=>$val['id'],'page'=>$data['nowpage']]); ?>"><i class="icon-search icon-large"></i></a>
                    </p>
                    <p class="width9 checkbox checkbox-off float-r">
                        <input type="hidden" name="<?= $val['id']?>" value="0">
                    </p>
                </li>
            <?php endforeach;?>
        <?php endif;?>
    </ul>
    <div class="box-footer">
        <ul class="page float-l">
            <li><a href="<?= Url::to(['/join','page'=>$data['backpage']]); ?>"><i class="icon-angle-left"></i></a></li>
            <?php for($i=1 ; $i<=$data['page'] ; $i++):?>
                <?php if($data['nowpage']==$i):?>
                    <li><a href="<?= Url::to(['/join','page'=>$i]); ?>" class="page-o"><?= $i;?></a></li>
                <?php else:?>
                    <li><a href="<?= Url::to(['/join','page'=>$i]); ?>" class="page-n"><?= $i;?></a></li>
                <?php endif?>
            <?php endfor;?>
            <li><a href="<?= Url::to(['/join','page'=>$data['frontpage']]); ?>"><i class="icon-angle-right"></i></a></li>
        </ul>
        <div class="box-footer-button">
            <a href="javascript:void(0)" id="delete" class="update-action"><i class="icon-random"><br/><span>批量操作</span></i></a>
            <span class="red hint"></span>
        </div>
    </div>
</div>
<script type="text/javascript">
    //复选框点击样式
    var inputs=new Array();
    var id;
    $('.checkbox').on('click',function(){
        a=$(this).children('input').val();
        if(a==0){
            $(this).addClass('checkbox-on');
            $(this).removeClass('checkbox-off');
            $(this).children('input').val(1);
            id=$(this).children('input').attr('name');
        }else{
            $(this).addClass('checkbox-off');
            $(this).removeClass('checkbox-on');
            $(this).children('input').val(0)
            id=$(this).children('input').attr('name');
        }
        if($.inArray(id,inputs)!=-1){
            inputs.splice($.inArray(id,inputs),1);
            console.log(inputs)
        }else{
            inputs.unshift(id);
            console.log(inputs)
        }
        /*console.log(inputs)*/
    });
    $('#delete').click(function(){
            if(inputs.length==0){
                $('.hint').html('至少选择一条数据!');
                return;
            }
            var statuss=$('.input-select').val()
            if(statuss==-1){
                $('.hint').html('请选择批量操作的类型!');
                return;
            }
            $('.input-select').val()
            $.ajax({
                type:'post',
                data: {_csrf:'<?= Yii::$app->request->csrfToken ?>', data:inputs, status:statuss},
                url:'<?= Url::to(['join/updateall']);?>',
                success:function(response,status,xhr){
                    window.location.reload();
                    //console.log(response);
                }
            });
        }
    );
    //面包屑标签
    $('.ratings').append('<?= isset($info['rating'])? $info['rating']: '';?>');
    $('.define').append('<?= isset($info['define'])? $info['define']: '';?>');
</script>
</body>
</html>